import 'package:flutter/material.dart';
import 'package:yysk_app/widget/app_bar_back_widget.dart';
import 'package:yysk_app/widget/app_bar_title_widget.dart';

class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
  final String title;
  final BuildContext context;
  final List<Widget>? actions;
  final VoidCallback? onBack;
  final Widget? titleWidget;
  final bool isNeedWidget;
  final Color? backgroundColor;
  const CustomAppBar({
    super.key,
    required this.title,
    required this.context,
    this.actions,
    this.onBack,
    this.titleWidget = const Text(''),
    this.isNeedWidget = false,
    this.backgroundColor,
  });
  @override
  Widget build(BuildContext context) {
    return AppBar(
      title:
          isNeedWidget != true
              ? AppBarTitleWidget(
                title: title,
                backgroundColor: backgroundColor,
              )
              : titleWidget,
      leading: AppBarBackWidget(context: context, onBack: onBack),
      backgroundColor: Color.fromRGBO(255, 255, 255, 0),
      excludeHeaderSemantics: false,
      shadowColor: Color.fromRGBO(255, 255, 255, 0),
      surfaceTintColor: Color.fromRGBO(255, 255, 255, 0),
      foregroundColor: Color.fromRGBO(255, 255, 255, 0),
      actions: actions != null && actions!.isNotEmpty ? actions : [],
    );
  }

  @override
  Size get preferredSize => const Size.fromHeight(kToolbarHeight);
}
